<template>
  <div class="tag-customers" :style="siteContentViewHeight">
    <div class="navbar-wrap">
      <div
        class="nav-btn nav-btn__1"
        :class="{ 'is-active': groupName === 'asideMine' }"
        @click="changeGroup('asideMine')"
      >
        <span>我的分析</span>
      </div>
      <div
        class="nav-btn nav-btn__2"
        :class="{ 'is-active': groupName === 'asideAll' }"
        @click="changeGroup('asideAll')"
      >
        <span>共享分析</span>
      </div>
    </div>
    <div class="customers-mine" v-if="groupName === 'asideMine'">
      <aside-mine ref="asideMine" @selectData="selectData"></aside-mine>
    </div>
    <div class="customers-all" v-if="groupName === 'asideAll'">
      <aside-all ref="asideAll" @selectData="selectData"></aside-all>
    </div>
    <content-item
      ref="contentItem"
      :config="configData"
      :type="groupName"
      @editSave="editSave"
      @deleteData="deleteData"
    ></content-item>
  </div>
</template>

<script>
import asideMine from './aside/aside-mine-item'
import asideAll from './aside/aside-all-item'
import contentItem from './content/content-item'
export default {
  components: {
    asideMine,
    asideAll,
    contentItem
  },
  data() {
    return {
      groupName: 'asideMine',
      loading: false,
      configData: {}
    }
  },
  computed: {
    siteContentViewHeight() {
      return { height: this.$store.getters['common/siteContentViewHeight'] + 'px' }
    }
  },
  methods: {
    changeGroup(groupName) {
      this.groupName = groupName
    },
    selectData(data) {
      this.configData = data
    },
    editSave() {
      this.$refs.asideMine && this.$refs.asideMine.getDataList()
    },
    deleteData() {
      this.configData = {}
      this.$refs.asideMine && this.$refs.asideMine.deleteData()
    }
  }
}
</script>

<style lang="scss">
.tag-customers {
  padding: 0 10px;
  position: relative;
  .navbar-wrap {
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 36px;
    border-right: 1px solid #dedede;
    z-index: 100;
    .nav-btn {
      font-size: 16px;
      position: absolute;
      padding: 18px 8px;
      background-color: #e8f0ff;
      text-align: center;
      border-right: 1px solid #dedede;
      border-bottom: 1px solid #dedede;
      line-height: 28px;
      margin-top: -2px;
      border-radius: 8px;
      box-shadow: #d0cccc 0 2px 2px;
      cursor: pointer;
      &.nav-btn__1 {
        border-top-left-radius: unset;
        z-index: 4;
      }
      &.nav-btn__2 {
        top: 140px;
        z-index: 3;
        border-bottom-left-radius: unset;
      }
      &.is-active {
        background-color: #4d82e9;
        color: #fff;
        font-weight: bold;
        z-index: 100;
      }
    }
  }
  .customers-aside {
    width: 320px;
    padding: 0 0px 24px 36px;
    background-color: #f6f7f8;
    position: absolute;
    top: 0;
    left: 10px;
    bottom: 0;
    overflow: auto;
    box-shadow: 1px 1px 2px #ddd;
    .search-header {
      display: flex;
      align-items: center;
      justify-content: space-around;
      padding: 0 8px;
      margin-bottom: 10px;
      .el-input {
        width: 200px;
      }
      .el-input__suffix {
        top: 5px;
      }
      .el-input__suffix-inner {
        font-size: 18px;
        color: #4d82e9;
      }
      .el-input-group__append {
        padding: 0 15px;
        color: #fff;
        background-color: #455fbc;
        border-color: #455fbc;
        i {
          font-size: 17px;
        }
      }
      .add-btn {
        height: 33px;
        margin-left: 10px;
        padding: 0 15px;
        color: #455fbc;
        background-color: #e4eafe;
        border-color: #e4eafe;
        svg {
          width: 18px;
          height: 18px;
        }
      }
    }
    .el-collapse {
      .el-collapse-item__header {
        font-size: 16px;
        height: 45px;
        padding: 0 10px;
        line-height: 45px;
        &:hover {
          background-color: #efefef;
        }
      }
      .el-collapse-item__arrow {
        display: none;
      }
      .icon-toggle {
        font-size: 18px;
        color: #4d82e9;
      }
      .el-collapse-item__content {
        padding-bottom: 0;
      }
      .group-title {
        width: 100%;
        position: relative;
        padding-right: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        .name {
          margin-left: 10px;
        }
      }
      .group-handler {
        color: #4d82e9;
        position: absolute;
        top: 15px;
        right: 0;
      }
      .list-wrap {
        padding: 10px;
      }
      .list-item {
        padding: 10px;
        display: flex;
        align-items: center;
        flex-wrap: nowrap;
        cursor: pointer;
        &:hover {
          color: #778cda;
          background-color: #efefef;
        }
        &.is-active {
          color: #778cda;
          background-color: #efefef;
        }
        .list-name {
          margin-left: 8px;
          flex: 1;
        }
        i {
          font-size: 18px;
          line-height: 23px;
          &.el-icon-success {
            color: $tag-green;
          }
          &.el-icon-error {
            color: $tag-red;
          }
        }
      }
    }
    .no-record {
      padding: 20px 0;
      text-align: center;
      img {
        margin-bottom: 10px;
      }
    }
  }
}
</style>
